package com.lnkwe.controller;

import com.lnkwe.sys.model.SysStatistics;
import com.lnkwe.sys.service.SysStatisticsService;
import com.lnkwe.util.UserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by lingwo on 2016/10/18.
 */
@Controller
@RequestMapping()
public class HomeController {
    @Autowired
    SysStatisticsService sysStatisticsService;

    @RequestMapping("/home")
    public ModelAndView home(HttpServletRequest request) {
        ModelAndView view = new ModelAndView();
        view.setViewName("/home");
        try {
            Map<String, Object> map = new HashMap<>();
            map.put("creatorId", UserUtil.getSysUserId(request));
            SysStatistics model = sysStatisticsService.total(map);
            view.addObject("model", model);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return view;
    }
}
